<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-2"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-3"></span><span class="hs-comment">--</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Compiler information functions</span><span>
</span><span id="line-5"></span><span class="hs-comment">--</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- (c) The GHC Team 2017</span><span>
</span><span id="line-7"></span><span class="hs-comment">--</span><span>
</span><span id="line-8"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.SysTools.Info</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Exception.html"><span class="hs-identifier">GHC.Utils.Exception</span></a></span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.IORef.html#"><span class="hs-identifier">Data.IORef</span></a></span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.SysTools.Process.html"><span class="hs-identifier">GHC.SysTools.Process</span></a></span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-comment">{- Note [Run-time linker info]

See also: #5240, #6063, #10110

Before 'runLink', we need to be sure to get the relevant information
about the linker we're using at runtime to see if we need any extra
options. For example, GNU ld requires '--reduce-memory-overheads' and
'--hash-size=31' in order to use reasonable amounts of memory (see
trac #5240.) But this isn't supported in GNU gold.

Generally, the linker changing from what was detected at ./configure
time has always been possible using -pgml, but on Linux it can happen
'transparently' by installing packages like binutils-gold, which
change what /usr/bin/ld actually points to.

Clang vs GCC notes:

For gcc, 'gcc -Wl,--version' gives a bunch of output about how to
invoke the linker before the version information string. For 'clang',
the version information for 'ld' is all that's output. For this
reason, we typically need to slurp up all of the standard error output
and look through it.

Other notes:

We cache the LinkerInfo inside DynFlags, since clients may link
multiple times. The definition of LinkerInfo is there to avoid a
circular dependency.

-}</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">{- Note [ELF needed shared libs]

Some distributions change the link editor's default handling of
ELF DT_NEEDED tags to include only those shared objects that are
needed to resolve undefined symbols. For Template Haskell we need
the last temporary shared library also if it is not needed for the
currently linked temporary shared library. We specify --no-as-needed
to override the default. This flag exists in GNU ld and GNU gold.

The flag is only needed on ELF systems. On Windows (PE) and Mac OS X
(Mach-O) the flag is not needed.

-}</span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-comment">{- Note [Windows static libGCC]

The GCC versions being upgraded to in #10726 are configured with
dynamic linking of libgcc supported. This results in libgcc being
linked dynamically when a shared library is created.

This introduces thus an extra dependency on GCC dll that was not
needed before by shared libraries created with GHC. This is a particular
issue on Windows because you get a non-obvious error due to this missing
dependency. This dependent dll is also not commonly on your path.

For this reason using the static libgcc is preferred as it preserves
the same behaviour that existed before. There are however some very good
reasons to have the shared version as well as described on page 181 of
https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc.pdf :

&quot;There are several situations in which an application should use the
 shared &#8216;libgcc&#8217; instead of the static version. The most common of these
 is when the application wishes to throw and catch exceptions across different
 shared libraries. In that case, each of the libraries as well as the application
 itself should use the shared &#8216;libgcc&#8217;. &quot;

-}</span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="annot"><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-type">neededLinkArgs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#LinkerInfo"><span class="hs-identifier hs-type">LinkerInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-type">Option</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-97"></span><span id="neededLinkArgs"><span class="annot"><span class="annottext">neededLinkArgs :: LinkerInfo -&gt; [Option]
</span><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-var hs-var">neededLinkArgs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#GnuLD"><span class="hs-identifier hs-type">GnuLD</span></a></span><span> </span><span id="local-6989586621680945225"><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945225"><span class="hs-identifier hs-var">o</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945225"><span class="hs-identifier hs-var">o</span></a></span><span>
</span><span id="line-98"></span><span class="annot"><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-var">neededLinkArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#GnuGold"><span class="hs-identifier hs-type">GnuGold</span></a></span><span> </span><span id="local-6989586621680945223"><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945223"><span class="hs-identifier hs-var">o</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945223"><span class="hs-identifier hs-var">o</span></a></span><span>
</span><span id="line-99"></span><span class="annot"><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-var">neededLinkArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#LlvmLLD"><span class="hs-identifier hs-type">LlvmLLD</span></a></span><span> </span><span id="local-6989586621680945221"><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945221"><span class="hs-identifier hs-var">o</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945221"><span class="hs-identifier hs-var">o</span></a></span><span>
</span><span id="line-100"></span><span class="annot"><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-var">neededLinkArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#DarwinLD"><span class="hs-identifier hs-type">DarwinLD</span></a></span><span> </span><span id="local-6989586621680945219"><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945219"><span class="hs-identifier hs-var">o</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945219"><span class="hs-identifier hs-var">o</span></a></span><span>
</span><span id="line-101"></span><span class="annot"><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-var">neededLinkArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#SolarisLD"><span class="hs-identifier hs-type">SolarisLD</span></a></span><span> </span><span id="local-6989586621680945217"><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945217"><span class="hs-identifier hs-var">o</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945217"><span class="hs-identifier hs-var">o</span></a></span><span>
</span><span id="line-102"></span><span class="annot"><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-var">neededLinkArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#AixLD"><span class="hs-identifier hs-type">AixLD</span></a></span><span> </span><span id="local-6989586621680945215"><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945215"><span class="hs-identifier hs-var">o</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945215"><span class="hs-identifier hs-var">o</span></a></span><span>
</span><span id="line-103"></span><span class="annot"><a href="GHC.SysTools.Info.html#neededLinkArgs"><span class="hs-identifier hs-var">neededLinkArgs</span></a></span><span> </span><span class="annot"><span class="annottext">LinkerInfo
</span><a href="GHC.Driver.Session.html#UnknownLD"><span class="hs-identifier hs-var">UnknownLD</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-comment">-- Grab linker info and cache it in DynFlags.</span><span>
</span><span id="line-106"></span><span class="annot"><a href="GHC.SysTools.Info.html#getLinkerInfo"><span class="hs-identifier hs-type">getLinkerInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#LinkerInfo"><span class="hs-identifier hs-type">LinkerInfo</span></a></span><span>
</span><span id="line-107"></span><span id="getLinkerInfo"><span class="annot"><span class="annottext">getLinkerInfo :: DynFlags -&gt; IO LinkerInfo
</span><a href="GHC.SysTools.Info.html#getLinkerInfo"><span class="hs-identifier hs-var hs-var">getLinkerInfo</span></a></span></span><span> </span><span id="local-6989586621680945212"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945212"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-108"></span><span>  </span><span id="local-6989586621680945211"><span class="annot"><span class="annottext">Maybe LinkerInfo
</span><a href="#local-6989586621680945211"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe LinkerInfo) -&gt; IO (Maybe LinkerInfo)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; IORef (Maybe LinkerInfo)
</span><a href="GHC.Driver.Session.html#rtldInfo"><span class="hs-identifier hs-var hs-var">rtldInfo</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945212"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe LinkerInfo
</span><a href="#local-6989586621680945211"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-110"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680945208"><span class="annot"><span class="annottext">LinkerInfo
</span><a href="#local-6989586621680945208"><span class="hs-identifier hs-var">v</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LinkerInfo
</span><a href="#local-6989586621680945208"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-111"></span><span>    </span><span class="annot"><span class="annottext">Maybe LinkerInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-112"></span><span>      </span><span id="local-6989586621680945207"><span class="annot"><span class="annottext">LinkerInfo
</span><a href="#local-6989586621680945207"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; IO LinkerInfo
</span><a href="GHC.SysTools.Info.html#getLinkerInfo%27"><span class="hs-identifier hs-var">getLinkerInfo'</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945212"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-113"></span><span>      </span><span class="annot"><span class="annottext">IORef (Maybe LinkerInfo) -&gt; Maybe LinkerInfo -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; IORef (Maybe LinkerInfo)
</span><a href="GHC.Driver.Session.html#rtldInfo"><span class="hs-identifier hs-var hs-var">rtldInfo</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945212"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LinkerInfo -&gt; Maybe LinkerInfo
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">LinkerInfo
</span><a href="#local-6989586621680945207"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span>      </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LinkerInfo
</span><a href="#local-6989586621680945207"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-115"></span><span>
</span><span id="line-116"></span><span class="hs-comment">-- See Note [Run-time linker info].</span><span>
</span><span id="line-117"></span><span class="annot"><a href="GHC.SysTools.Info.html#getLinkerInfo%27"><span class="hs-identifier hs-type">getLinkerInfo'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#LinkerInfo"><span class="hs-identifier hs-type">LinkerInfo</span></a></span><span>
</span><span id="line-118"></span><span id="getLinkerInfo%27"><span class="annot"><span class="annottext">getLinkerInfo' :: DynFlags -&gt; IO LinkerInfo
</span><a href="GHC.SysTools.Info.html#getLinkerInfo%27"><span class="hs-identifier hs-var hs-var">getLinkerInfo'</span></a></span></span><span> </span><span id="local-6989586621680945204"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945204"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-119"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680945203"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621680945203"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945204"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-120"></span><span>      </span><span id="local-6989586621680945201"><span class="annot"><span class="annottext">os :: OS
</span><a href="#local-6989586621680945201"><span class="hs-identifier hs-var hs-var">os</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformOS"><span class="hs-identifier hs-var">platformOS</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621680945203"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-121"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680945199"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945199"><span class="hs-identifier hs-var">pgm</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680945198"><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945198"><span class="hs-identifier hs-var">args0</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; (String, [Option])
</span><a href="GHC.Driver.Session.html#pgm_l"><span class="hs-identifier hs-var">pgm_l</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945204"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-122"></span><span>      </span><span id="local-6989586621680945196"><span class="annot"><span class="annottext">args1 :: [Option]
</span><a href="#local-6989586621680945196"><span class="hs-identifier hs-var hs-var">args1</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; (DynFlags -&gt; [String]) -&gt; [String]
forall a. DynFlags -&gt; (DynFlags -&gt; [a]) -&gt; [a]
</span><a href="GHC.Driver.Session.html#getOpts"><span class="hs-identifier hs-var">getOpts</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945204"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [String]
</span><a href="GHC.Driver.Session.html#opt_l"><span class="hs-identifier hs-var">opt_l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span>      </span><span id="local-6989586621680945192"><span class="annot"><span class="annottext">args2 :: [Option]
</span><a href="#local-6989586621680945192"><span class="hs-identifier hs-var hs-var">args2</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945198"><span class="hs-identifier hs-var">args0</span></a></span><span> </span><span class="annot"><span class="annottext">[Option] -&gt; [Option] -&gt; [Option]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945196"><span class="hs-identifier hs-var">args1</span></a></span><span>
</span><span id="line-124"></span><span>      </span><span id="local-6989586621680945191"><span class="annot"><span class="annottext">args3 :: [String]
</span><a href="#local-6989586621680945191"><span class="hs-identifier hs-var hs-var">args3</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; [String]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
forall a. [a] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#notNull"><span class="hs-identifier hs-var">notNull</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Option -&gt; String) -&gt; [Option] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Option -&gt; String
</span><a href="GHC.Utils.CliOption.html#showOpt"><span class="hs-identifier hs-var">showOpt</span></a></span><span> </span><span class="annot"><span class="annottext">[Option]
</span><a href="#local-6989586621680945192"><span class="hs-identifier hs-var">args2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span>      </span><span class="hs-comment">-- Try to grab the info from the process output.</span><span>
</span><span id="line-127"></span><span>      </span><span id="local-6989586621680945173"><span class="annot"><span class="annottext">parseLinkerInfo :: t String -&gt; p -&gt; p -&gt; m LinkerInfo
</span><a href="#local-6989586621680945173"><span class="hs-identifier hs-var hs-var">parseLinkerInfo</span></a></span></span><span> </span><span id="local-6989586621680945172"><span class="annot"><span class="annottext">t String
</span><a href="#local-6989586621680945172"><span class="hs-identifier hs-var">stdo</span></a></span></span><span> </span><span id="local-6989586621680945171"><span class="annot"><span class="annottext">p
</span><a href="#local-6989586621680945171"><span class="hs-identifier hs-var">_stde</span></a></span></span><span> </span><span id="local-6989586621680945170"><span class="annot"><span class="annottext">p
</span><a href="#local-6989586621680945170"><span class="hs-identifier hs-var">_exitc</span></a></span></span><span>
</span><span id="line-128"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; t String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GNU ld&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isPrefixOf"><span class="hs-operator hs-var">`isPrefixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">t String
</span><a href="#local-6989586621680945172"><span class="hs-identifier hs-var">stdo</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-129"></span><span>          </span><span class="hs-comment">-- GNU ld specifically needs to use less memory. This especially</span><span>
</span><span id="line-130"></span><span>          </span><span class="hs-comment">-- hurts on small object files. #5240.</span><span>
</span><span id="line-131"></span><span>          </span><span class="hs-comment">-- Set DT_NEEDED for all shared libraries. #10110.</span><span>
</span><span id="line-132"></span><span>          </span><span class="hs-comment">-- TODO: Investigate if these help or hurt when using split sections.</span><span>
</span><span id="line-133"></span><span>          </span><span class="annot"><span class="annottext">LinkerInfo -&gt; m LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Option] -&gt; LinkerInfo
</span><a href="GHC.Driver.Session.html#GnuLD"><span class="hs-identifier hs-var">GnuLD</span></a></span><span> </span><span class="annot"><span class="annottext">([Option] -&gt; LinkerInfo) -&gt; [Option] -&gt; LinkerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--hash-size=31&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-134"></span><span>                                      </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--reduce-memory-overheads&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-135"></span><span>                                      </span><span class="hs-comment">-- ELF specific flag</span><span>
</span><span id="line-136"></span><span>                                      </span><span class="hs-comment">-- see Note [ELF needed shared libs]</span><span>
</span><span id="line-137"></span><span>                                      </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--no-as-needed&quot;</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-138"></span><span>
</span><span id="line-139"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; t String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GNU gold&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isPrefixOf"><span class="hs-operator hs-var">`isPrefixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">t String
</span><a href="#local-6989586621680945172"><span class="hs-identifier hs-var">stdo</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-140"></span><span>          </span><span class="hs-comment">-- GNU gold only needs --no-as-needed. #10110.</span><span>
</span><span id="line-141"></span><span>          </span><span class="hs-comment">-- ELF specific flag, see Note [ELF needed shared libs]</span><span>
</span><span id="line-142"></span><span>          </span><span class="annot"><span class="annottext">LinkerInfo -&gt; m LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Option] -&gt; LinkerInfo
</span><a href="GHC.Driver.Session.html#GnuGold"><span class="hs-identifier hs-var">GnuGold</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--no-as-needed&quot;</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-143"></span><span>
</span><span id="line-144"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; t String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;LLD&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isPrefixOf"><span class="hs-operator hs-var">`isPrefixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">t String
</span><a href="#local-6989586621680945172"><span class="hs-identifier hs-var">stdo</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-145"></span><span>          </span><span class="annot"><span class="annottext">LinkerInfo -&gt; m LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Option] -&gt; LinkerInfo
</span><a href="GHC.Driver.Session.html#LlvmLLD"><span class="hs-identifier hs-var">LlvmLLD</span></a></span><span> </span><span class="annot"><span class="annottext">([Option] -&gt; LinkerInfo) -&gt; [Option] -&gt; LinkerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-146"></span><span>                                      </span><span class="hs-comment">-- see Note [ELF needed shared libs]</span><span>
</span><span id="line-147"></span><span>                                      </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--no-as-needed&quot;</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span>         </span><span class="hs-comment">-- Unknown linker.</span><span>
</span><span id="line-150"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; m LinkerInfo
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;invalid --version output, or linker is unsupported&quot;</span></span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span>  </span><span class="hs-comment">-- Process the executable call</span><span>
</span><span id="line-153"></span><span>  </span><span id="local-6989586621680945167"><span class="annot"><span class="annottext">LinkerInfo
</span><a href="#local-6989586621680945167"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO LinkerInfo -&gt; (IOException -&gt; IO LinkerInfo) -&gt; IO LinkerInfo
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-identifier hs-var">catchIO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">do</span><span>
</span><span id="line-154"></span><span>             </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OS
</span><a href="#local-6989586621680945201"><span class="hs-identifier hs-var">os</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-155"></span><span>               </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSSolaris2"><span class="hs-identifier hs-var">OSSolaris2</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-156"></span><span>                 </span><span class="hs-comment">-- Solaris uses its own Solaris linker. Even all</span><span>
</span><span id="line-157"></span><span>                 </span><span class="hs-comment">-- GNU C are recommended to configure with Solaris</span><span>
</span><span id="line-158"></span><span>                 </span><span class="hs-comment">-- linker instead of using GNU binutils linker. Also</span><span>
</span><span id="line-159"></span><span>                 </span><span class="hs-comment">-- all GCC distributed with Solaris follows this rule</span><span>
</span><span id="line-160"></span><span>                 </span><span class="hs-comment">-- precisely so we assume here, the Solaris linker is</span><span>
</span><span id="line-161"></span><span>                 </span><span class="hs-comment">-- used.</span><span>
</span><span id="line-162"></span><span>                 </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(LinkerInfo -&gt; IO LinkerInfo) -&gt; LinkerInfo -&gt; IO LinkerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Option] -&gt; LinkerInfo
</span><a href="GHC.Driver.Session.html#SolarisLD"><span class="hs-identifier hs-var">SolarisLD</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-163"></span><span>               </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSAIX"><span class="hs-identifier hs-var">OSAIX</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-164"></span><span>                 </span><span class="hs-comment">-- IBM AIX uses its own non-binutils linker as well</span><span>
</span><span id="line-165"></span><span>                 </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(LinkerInfo -&gt; IO LinkerInfo) -&gt; LinkerInfo -&gt; IO LinkerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Option] -&gt; LinkerInfo
</span><a href="GHC.Driver.Session.html#AixLD"><span class="hs-identifier hs-var">AixLD</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-166"></span><span>               </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSDarwin"><span class="hs-identifier hs-var">OSDarwin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-167"></span><span>                 </span><span class="hs-comment">-- Darwin has neither GNU Gold or GNU LD, but a strange linker</span><span>
</span><span id="line-168"></span><span>                 </span><span class="hs-comment">-- that doesn't support --version. We can just assume that's</span><span>
</span><span id="line-169"></span><span>                 </span><span class="hs-comment">-- what we're using.</span><span>
</span><span id="line-170"></span><span>                 </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(LinkerInfo -&gt; IO LinkerInfo) -&gt; LinkerInfo -&gt; IO LinkerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Option] -&gt; LinkerInfo
</span><a href="GHC.Driver.Session.html#DarwinLD"><span class="hs-identifier hs-var">DarwinLD</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-171"></span><span>               </span><span class="annot"><span class="annottext">OS
</span><a href="../../ghc-boot/src/GHC.Platform.html#OSMinGW32"><span class="hs-identifier hs-var">OSMinGW32</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-172"></span><span>                 </span><span class="hs-comment">-- GHC doesn't support anything but GNU ld on Windows anyway.</span><span>
</span><span id="line-173"></span><span>                 </span><span class="hs-comment">-- Process creation is also fairly expensive on win32, so</span><span>
</span><span id="line-174"></span><span>                 </span><span class="hs-comment">-- we short-circuit here.</span><span>
</span><span id="line-175"></span><span>                 </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(LinkerInfo -&gt; IO LinkerInfo) -&gt; LinkerInfo -&gt; IO LinkerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Option] -&gt; LinkerInfo
</span><a href="GHC.Driver.Session.html#GnuLD"><span class="hs-identifier hs-var">GnuLD</span></a></span><span> </span><span class="annot"><span class="annottext">([Option] -&gt; LinkerInfo) -&gt; [Option] -&gt; LinkerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Option) -&gt; [String] -&gt; [Option]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Option
</span><a href="GHC.Utils.CliOption.html#Option"><span class="hs-identifier hs-var">Option</span></a></span><span>
</span><span id="line-176"></span><span>                   </span><span class="hs-special">[</span><span> </span><span class="hs-comment">-- Reduce ld memory usage</span><span>
</span><span id="line-177"></span><span>                     </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--hash-size=31&quot;</span></span><span>
</span><span id="line-178"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--reduce-memory-overheads&quot;</span></span><span>
</span><span id="line-179"></span><span>                     </span><span class="hs-comment">-- Emit gcc stack checks</span><span>
</span><span id="line-180"></span><span>                     </span><span class="hs-comment">-- Note [Windows stack usage]</span><span>
</span><span id="line-181"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-fstack-check&quot;</span></span><span>
</span><span id="line-182"></span><span>                     </span><span class="hs-comment">-- Force static linking of libGCC</span><span>
</span><span id="line-183"></span><span>                     </span><span class="hs-comment">-- Note [Windows static libGCC]</span><span>
</span><span id="line-184"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-static-libgcc&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-185"></span><span>               </span><span class="annot"><span class="annottext">OS
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-186"></span><span>                 </span><span class="hs-comment">-- In practice, we use the compiler as the linker here. Pass</span><span>
</span><span id="line-187"></span><span>                 </span><span class="hs-comment">-- -Wl,--version to get linker version info.</span><span>
</span><span id="line-188"></span><span>                 </span><span class="hs-special">(</span><span id="local-6989586621680945161"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621680945161"><span class="hs-identifier hs-var">exitc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680945160"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945160"><span class="hs-identifier hs-var">stdo</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680945159"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945159"><span class="hs-identifier hs-var">stde</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String
-&gt; [String] -&gt; (String, String) -&gt; IO (ExitCode, String, String)
</span><a href="GHC.SysTools.Process.html#readProcessEnvWithExitCode"><span class="hs-identifier hs-var">readProcessEnvWithExitCode</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945199"><span class="hs-identifier hs-var">pgm</span></a></span><span>
</span><span id="line-189"></span><span>                                        </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-Wl,--version&quot;</span></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; [String]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945191"><span class="hs-identifier hs-var">args3</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-190"></span><span>                                        </span><span class="annot"><span class="annottext">(String, String)
</span><a href="GHC.SysTools.Process.html#c_locale_env"><span class="hs-identifier hs-var">c_locale_env</span></a></span><span>
</span><span id="line-191"></span><span>                 </span><span class="hs-comment">-- Split the output by lines to make certain kinds</span><span>
</span><span id="line-192"></span><span>                 </span><span class="hs-comment">-- of processing easier. In particular, 'clang' and 'gcc'</span><span>
</span><span id="line-193"></span><span>                 </span><span class="hs-comment">-- have slightly different outputs for '-Wl,--version', but</span><span>
</span><span id="line-194"></span><span>                 </span><span class="hs-comment">-- it's still easy to figure out.</span><span>
</span><span id="line-195"></span><span>                 </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; ExitCode -&gt; IO LinkerInfo
forall {t :: * -&gt; *} {m :: * -&gt; *} {p} {p}.
(Foldable t, MonadFail m) =&gt;
t String -&gt; p -&gt; p -&gt; m LinkerInfo
</span><a href="#local-6989586621680945173"><span class="hs-identifier hs-var">parseLinkerInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#lines"><span class="hs-identifier hs-var">lines</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945160"><span class="hs-identifier hs-var">stdo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#lines"><span class="hs-identifier hs-var">lines</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945159"><span class="hs-identifier hs-var">stde</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621680945161"><span class="hs-identifier hs-var">exitc</span></a></span><span>
</span><span id="line-196"></span><span>            </span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span>            </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680945155"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621680945155"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-198"></span><span>                </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945204"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span>
</span><span id="line-199"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Error (figuring out linker information):&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-200"></span><span>                     </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621680945155"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>                </span><span class="annot"><span class="annottext">DynFlags -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#errorMsg"><span class="hs-identifier hs-var">errorMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945204"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Int -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Warning:&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">9</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; MsgDoc) -&gt; MsgDoc -&gt; MsgDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-202"></span><span>                  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Couldn't figure out linker information!&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-203"></span><span>                  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Make sure you're using GNU ld, GNU gold&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-204"></span><span>                  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;or the built in OS X linker, etc.&quot;</span></span><span>
</span><span id="line-205"></span><span>                </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LinkerInfo
</span><a href="GHC.Driver.Session.html#UnknownLD"><span class="hs-identifier hs-var">UnknownLD</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-206"></span><span>  </span><span class="annot"><span class="annottext">LinkerInfo -&gt; IO LinkerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LinkerInfo
</span><a href="#local-6989586621680945167"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-207"></span><span>
</span><span id="line-208"></span><span class="hs-comment">-- Grab compiler info and cache it in DynFlags.</span><span>
</span><span id="line-209"></span><span class="annot"><a href="GHC.SysTools.Info.html#getCompilerInfo"><span class="hs-identifier hs-type">getCompilerInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#CompilerInfo"><span class="hs-identifier hs-type">CompilerInfo</span></a></span><span>
</span><span id="line-210"></span><span id="getCompilerInfo"><span class="annot"><span class="annottext">getCompilerInfo :: DynFlags -&gt; IO CompilerInfo
</span><a href="GHC.SysTools.Info.html#getCompilerInfo"><span class="hs-identifier hs-var hs-var">getCompilerInfo</span></a></span></span><span> </span><span id="local-6989586621680945146"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945146"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-211"></span><span>  </span><span id="local-6989586621680945145"><span class="annot"><span class="annottext">Maybe CompilerInfo
</span><a href="#local-6989586621680945145"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe CompilerInfo) -&gt; IO (Maybe CompilerInfo)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; IORef (Maybe CompilerInfo)
</span><a href="GHC.Driver.Session.html#rtccInfo"><span class="hs-identifier hs-var hs-var">rtccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945146"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-212"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe CompilerInfo
</span><a href="#local-6989586621680945145"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-213"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680945143"><span class="annot"><span class="annottext">CompilerInfo
</span><a href="#local-6989586621680945143"><span class="hs-identifier hs-var">v</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CompilerInfo -&gt; IO CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="#local-6989586621680945143"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-214"></span><span>    </span><span class="annot"><span class="annottext">Maybe CompilerInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-215"></span><span>      </span><span id="local-6989586621680945142"><span class="annot"><span class="annottext">CompilerInfo
</span><a href="#local-6989586621680945142"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; IO CompilerInfo
</span><a href="GHC.SysTools.Info.html#getCompilerInfo%27"><span class="hs-identifier hs-var">getCompilerInfo'</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945146"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-216"></span><span>      </span><span class="annot"><span class="annottext">IORef (Maybe CompilerInfo) -&gt; Maybe CompilerInfo -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; IORef (Maybe CompilerInfo)
</span><a href="GHC.Driver.Session.html#rtccInfo"><span class="hs-identifier hs-var hs-var">rtccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945146"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CompilerInfo -&gt; Maybe CompilerInfo
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="#local-6989586621680945142"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>      </span><span class="annot"><span class="annottext">CompilerInfo -&gt; IO CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="#local-6989586621680945142"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-218"></span><span>
</span><span id="line-219"></span><span class="hs-comment">-- See Note [Run-time linker info].</span><span>
</span><span id="line-220"></span><span class="annot"><a href="GHC.SysTools.Info.html#getCompilerInfo%27"><span class="hs-identifier hs-type">getCompilerInfo'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#CompilerInfo"><span class="hs-identifier hs-type">CompilerInfo</span></a></span><span>
</span><span id="line-221"></span><span id="getCompilerInfo%27"><span class="annot"><span class="annottext">getCompilerInfo' :: DynFlags -&gt; IO CompilerInfo
</span><a href="GHC.SysTools.Info.html#getCompilerInfo%27"><span class="hs-identifier hs-var hs-var">getCompilerInfo'</span></a></span></span><span> </span><span id="local-6989586621680945140"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945140"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-222"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680945139"><span class="annot"><span class="annottext">pgm :: String
</span><a href="#local-6989586621680945139"><span class="hs-identifier hs-var hs-var">pgm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; String
</span><a href="GHC.Driver.Session.html#pgm_c"><span class="hs-identifier hs-var">pgm_c</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945140"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-223"></span><span>      </span><span class="hs-comment">-- Try to grab the info from the process output.</span><span>
</span><span id="line-224"></span><span>      </span><span id="local-6989586621680945116"><span class="annot"><span class="annottext">parseCompilerInfo :: p -&gt; [String] -&gt; p -&gt; m CompilerInfo
</span><a href="#local-6989586621680945116"><span class="hs-identifier hs-var hs-var">parseCompilerInfo</span></a></span></span><span> </span><span id="local-6989586621680945115"><span class="annot"><span class="annottext">p
</span><a href="#local-6989586621680945115"><span class="hs-identifier hs-var">_stdo</span></a></span></span><span> </span><span id="local-6989586621680945114"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span></span><span> </span><span id="local-6989586621680945113"><span class="annot"><span class="annottext">p
</span><a href="#local-6989586621680945113"><span class="hs-identifier hs-var">_exitc</span></a></span></span><span>
</span><span id="line-225"></span><span>        </span><span class="hs-comment">-- Regular GCC</span><span>
</span><span id="line-226"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;gcc version&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isInfixOf"><span class="hs-operator hs-var">`isInfixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-227"></span><span>          </span><span class="annot"><span class="annottext">CompilerInfo -&gt; m CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="GHC.Driver.Session.html#GCC"><span class="hs-identifier hs-var">GCC</span></a></span><span>
</span><span id="line-228"></span><span>        </span><span class="hs-comment">-- Regular clang</span><span>
</span><span id="line-229"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;clang version&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isInfixOf"><span class="hs-operator hs-var">`isInfixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-230"></span><span>          </span><span class="annot"><span class="annottext">CompilerInfo -&gt; m CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="GHC.Driver.Session.html#Clang"><span class="hs-identifier hs-var">Clang</span></a></span><span>
</span><span id="line-231"></span><span>        </span><span class="hs-comment">-- FreeBSD clang</span><span>
</span><span id="line-232"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;FreeBSD clang version&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isInfixOf"><span class="hs-operator hs-var">`isInfixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-233"></span><span>          </span><span class="annot"><span class="annottext">CompilerInfo -&gt; m CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="GHC.Driver.Session.html#Clang"><span class="hs-identifier hs-var">Clang</span></a></span><span>
</span><span id="line-234"></span><span>        </span><span class="hs-comment">-- Xcode 5.1 clang</span><span>
</span><span id="line-235"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Apple LLVM version 5.1&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isPrefixOf"><span class="hs-operator hs-var">`isPrefixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-236"></span><span>          </span><span class="annot"><span class="annottext">CompilerInfo -&gt; m CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="GHC.Driver.Session.html#AppleClang51"><span class="hs-identifier hs-var">AppleClang51</span></a></span><span>
</span><span id="line-237"></span><span>        </span><span class="hs-comment">-- Xcode 5 clang</span><span>
</span><span id="line-238"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Apple LLVM version&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isPrefixOf"><span class="hs-operator hs-var">`isPrefixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-239"></span><span>          </span><span class="annot"><span class="annottext">CompilerInfo -&gt; m CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="GHC.Driver.Session.html#AppleClang"><span class="hs-identifier hs-var">AppleClang</span></a></span><span>
</span><span id="line-240"></span><span>        </span><span class="hs-comment">-- Xcode 4.1 clang</span><span>
</span><span id="line-241"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Apple clang version&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isPrefixOf"><span class="hs-operator hs-var">`isPrefixOf`</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-242"></span><span>          </span><span class="annot"><span class="annottext">CompilerInfo -&gt; m CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="GHC.Driver.Session.html#AppleClang"><span class="hs-identifier hs-var">AppleClang</span></a></span><span>
</span><span id="line-243"></span><span>         </span><span class="hs-comment">-- Unknown linker.</span><span>
</span><span id="line-244"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; m CompilerInfo
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">fail</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; m CompilerInfo) -&gt; String -&gt; m CompilerInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;invalid -v output, or compiler is unsupported: &quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String
</span><a href="../../base/src/Data.OldList.html#unlines"><span class="hs-identifier hs-var">unlines</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621680945114"><span class="hs-identifier hs-var">stde</span></a></span><span>
</span><span id="line-245"></span><span>
</span><span id="line-246"></span><span>  </span><span class="hs-comment">-- Process the executable call</span><span>
</span><span id="line-247"></span><span>  </span><span id="local-6989586621680945106"><span class="annot"><span class="annottext">CompilerInfo
</span><a href="#local-6989586621680945106"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO CompilerInfo
-&gt; (IOException -&gt; IO CompilerInfo) -&gt; IO CompilerInfo
forall a. IO a -&gt; (IOException -&gt; IO a) -&gt; IO a
</span><a href="GHC.Utils.Exception.html#catchIO"><span class="hs-identifier hs-var">catchIO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">do</span><span>
</span><span id="line-248"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621680945105"><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621680945105"><span class="hs-identifier hs-var">exitc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680945104"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945104"><span class="hs-identifier hs-var">stdo</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680945103"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945103"><span class="hs-identifier hs-var">stde</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-249"></span><span>                    </span><span class="annot"><span class="annottext">String
-&gt; [String] -&gt; (String, String) -&gt; IO (ExitCode, String, String)
</span><a href="GHC.SysTools.Process.html#readProcessEnvWithExitCode"><span class="hs-identifier hs-var">readProcessEnvWithExitCode</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945139"><span class="hs-identifier hs-var">pgm</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-v&quot;</span></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(String, String)
</span><a href="GHC.SysTools.Process.html#c_locale_env"><span class="hs-identifier hs-var">c_locale_env</span></a></span><span>
</span><span id="line-250"></span><span>                </span><span class="hs-comment">-- Split the output by lines to make certain kinds</span><span>
</span><span id="line-251"></span><span>                </span><span class="hs-comment">-- of processing easier.</span><span>
</span><span id="line-252"></span><span>                </span><span class="annot"><span class="annottext">[String] -&gt; [String] -&gt; ExitCode -&gt; IO CompilerInfo
forall {m :: * -&gt; *} {p} {p}.
MonadFail m =&gt;
p -&gt; [String] -&gt; p -&gt; m CompilerInfo
</span><a href="#local-6989586621680945116"><span class="hs-identifier hs-var">parseCompilerInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#lines"><span class="hs-identifier hs-var">lines</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945104"><span class="hs-identifier hs-var">stdo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#lines"><span class="hs-identifier hs-var">lines</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680945103"><span class="hs-identifier hs-var">stde</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ExitCode
</span><a href="#local-6989586621680945105"><span class="hs-identifier hs-var">exitc</span></a></span><span>
</span><span id="line-253"></span><span>            </span><span class="hs-special">)</span><span>
</span><span id="line-254"></span><span>            </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680945102"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621680945102"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-255"></span><span>                </span><span class="annot"><span class="annottext">DynFlags -&gt; Int -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#debugTraceMsg"><span class="hs-identifier hs-var">debugTraceMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945140"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span>
</span><span id="line-256"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Error (figuring out C compiler information):&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-257"></span><span>                     </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621680945102"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-258"></span><span>                </span><span class="annot"><span class="annottext">DynFlags -&gt; MsgDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#errorMsg"><span class="hs-identifier hs-var">errorMsg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680945140"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IO ()) -&gt; MsgDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Int -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Warning:&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">9</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; MsgDoc) -&gt; MsgDoc -&gt; MsgDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-259"></span><span>                  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Couldn't figure out C compiler information!&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-260"></span><span>                  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Make sure you're using GNU gcc, or clang&quot;</span></span><span>
</span><span id="line-261"></span><span>                </span><span class="annot"><span class="annottext">CompilerInfo -&gt; IO CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="GHC.Driver.Session.html#UnknownCC"><span class="hs-identifier hs-var">UnknownCC</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-262"></span><span>  </span><span class="annot"><span class="annottext">CompilerInfo -&gt; IO CompilerInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CompilerInfo
</span><a href="#local-6989586621680945106"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-263"></span></pre></body></html>